package com.atguigu.aiproject.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.Getter;

import java.time.LocalDateTime;

@Data
@TableName("chat_message")
public class ChatMessage {
    @TableId(type = IdType.AUTO)
    private Long id;
    @TableField(value = "sender_id")
    private Integer senderId;
    @TableField(value = "receiver_id")
    private Integer receiverId;
    @TableField(value = "content")
    private String content;
    @TableField(value = "message_type")
    private MessageType messageType;
    @TableField(value = "status")
    private MessageStatus status;
    @TableField(value = "send_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime sendTime;
    @TableField(value = "read_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime readTime;
    /**
     * 聊天消息类型
     */
    @Getter
    public enum MessageType {//返回给前端为大写
        TEXT("text"), IMAGE("image"), FILE("file");
        @EnumValue // 枚举值映射到数据库中
        private final String value;
        MessageType(String value) { this.value = value; }
    }
    /**
     * 聊天消息状态
     * 1.发送中 2.已送达 3.已读
     */
    @Getter
    public enum MessageStatus {//返回给前端为大写
        SENT(1), DELIVERED(2), READ(3);
        @EnumValue // 枚举值映射到数据库中
        private final int code;
        MessageStatus(int code) { this.code = code; }
    }
}